package com.atguigu.gmall.product.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.entity.BaseCategory1;
import com.atguigu.gmall.product.service.BaseCategory1Service;
import com.atguigu.gmall.product.to.CategoryTree;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//远程调用；路径命名方式；  /api/inner/服务名/路径
@RequestMapping("/api/inner/product")
@RestController
public class CategoryTreeRPCController {

//    CRUD重点功能
//    获取所有的分类，将其封装成树形结构

    @Autowired
    BaseCategory1Service baseCategory1;

//    查找所有数据
    @GetMapping("/category/tree")
    public Result getCategoryTreeData() {
        List<CategoryTree> categoryTrees  = baseCategory1.getCategoryTreeData();

        return Result.ok(categoryTrees);
    }
}
